package com.ha.web.controller.system.track.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ha.common.annotation.Log;
import com.ha.common.enums.BusinessType;
import com.ha.system.track.domain.HaOrderTrack;
import com.ha.system.track.service.IHaOrderTrackService;
import com.ha.common.core.controller.BaseController;
import com.ha.common.core.domain.AjaxResult;
import com.ha.common.utils.poi.ExcelUtil;
import com.ha.common.core.page.TableDataInfo;

/**
 * 订单信息追踪Controller
 * 
 * @author admin
 * @date 2021-03-16
 */
@Controller
@RequestMapping("/track/track")
public class HaOrderTrackController extends BaseController
{
    private String prefix = "track/track";

    @Autowired
    private IHaOrderTrackService haOrderTrackService;

    @RequiresPermissions("track:track:view")
    @GetMapping()
    public String track()
    {
        return prefix + "/track";
    }

    /**
     * 查询订单信息追踪列表
     */
    @RequiresPermissions("track:track:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HaOrderTrack haOrderTrack)
    {
        startPage();
        List<HaOrderTrack> list = haOrderTrackService.selectHaOrderTrackList(haOrderTrack);
        return getDataTable(list);
    }

    /**
     * 导出订单信息追踪列表
     */
    @RequiresPermissions("track:track:export")
    @Log(title = "订单信息追踪", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HaOrderTrack haOrderTrack)
    {
        List<HaOrderTrack> list = haOrderTrackService.selectHaOrderTrackList(haOrderTrack);
        ExcelUtil<HaOrderTrack> util = new ExcelUtil<HaOrderTrack>(HaOrderTrack.class);
        return util.exportExcel(list, "track");
    }

    /**
     * 新增订单信息追踪
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存订单信息追踪
     */
    @RequiresPermissions("track:track:add")
    @Log(title = "订单信息追踪", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(HaOrderTrack haOrderTrack)
    {
        return toAjax(haOrderTrackService.insertHaOrderTrack(haOrderTrack));
    }

    /**
     * 修改订单信息追踪
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        HaOrderTrack haOrderTrack = haOrderTrackService.selectHaOrderTrackById(id);
        mmap.put("haOrderTrack", haOrderTrack);
        return prefix + "/edit";
    }

    /**
     * 修改保存订单信息追踪
     */
    @RequiresPermissions("track:track:edit")
    @Log(title = "订单信息追踪", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(HaOrderTrack haOrderTrack)
    {
        return toAjax(haOrderTrackService.updateHaOrderTrack(haOrderTrack));
    }

    /**
     * 删除订单信息追踪
     */
    @RequiresPermissions("track:track:remove")
    @Log(title = "订单信息追踪", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(haOrderTrackService.deleteHaOrderTrackByIds(ids));
    }
}
